<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <div>
      <h1>父亲辛苦了{{ n }}</h1>
      <button @click = "bbb">让我儿子长高点</button>
    </div>
    <hr>
    <Child></Child>
  </div>

  <script src="./js/vue.js"></script>

  <script  id="child" type="text/x-template">
        <div>
            <h2>我是儿子{{num}}</h2>
            <button @click = "aaa">让我爸加十岁</button>
        </div>
  </script>


  <script>

const Child = {
  template :'#child',
  data(){
    return { num : 20 }
  },
  methods:{
    aaa(){
      this.$parent.n += 10
    }
  }
}
   

   const app = new Vue({
     el:'#app',
     data:{
       n:50
     },
     components: { Child },
     methods:{
       bbb(){
        this.$children[0].num +=1
       }
     }
   })



  </script>
</body>
</html>